Skip to content

Cleanup#279

Draft
Ozaq wants to merge 3 commits intodevelopfrom
cleanup
Draft

Cleanup#279
Ozaq wants to merge 3 commits intodevelopfrom
cleanup

Conversation

@Ozaq
Copy link
Member

@Ozaq Ozaq commented Feb 26, 2026

Description

commit b72c5fc
Author: Kai Kratz Kai.Kratz@ecmwf.int
Date: Thu Feb 26 20:20:43 2026 +0000

Add compile-time test to prevent header regressions

The IWYU cleanup made all public headers self-contained, but nothing
prevents regressions. Add a CMake test that compiles each header in
isolation — if a future change breaks self-containedness, the build
fails immediately pointing to the offending header.

Gated behind -DENABLE_TEST_SELF_CONTAINED_HEADERS=ON to avoid the
extra compile cost on regular builds.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

commit 9405716
Author: Kai Kratz Kai.Kratz@ecmwf.int
Date: Thu Feb 26 20:20:42 2026 +0000

Ensure headers are self-contained after IWYU cleanup

Downstream projects include eckit headers in arbitrary combinations
and orders. A header that silently depends on a transitive include
will break when unrelated changes elsewhere shuffle include graphs.

Run IWYU 0.25 across the codebase to add missing direct includes
and remove unnecessary ones, so every header compiles on its own.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

commit e82c6c4
Author: Kai Kratz Kai.Kratz@ecmwf.int
Date: Thu Feb 26 20:20:42 2026 +0000

Unify include guards to #pragma once

Traditional #ifndef guards are verbose, error-prone (copy-paste of
wrong macro names), and add noise to diffs. #pragma once is supported
by all compilers we target and eliminates these issues.

- Convert 489 headers from #ifndef guards to #pragma once
- Add #pragma once to 5 headers that had no guard at all
- Skip src/eckit/contrib/ (third-party code)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Contributor Declaration

By opening this pull request, I affirm the following:

  • All authors agree to the Contributor License Agreement.
  • The code follows the project's coding standards.
  • I have performed self-review and added comments where needed.
  • I have added or updated tests to verify that my changes are effective and functional.
  • I have run all existing tests and confirmed they pass.

🌦️ >> Documentation << 🌦️
https://sites.ecmwf.int/docs/dev-section/eckit/pull-requests/PR-279


#include "eckit/eckit.h"

#pragma once
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are touching all files, it would be nice to have a consistent spacing (my suggestion would be to consistently have an empty line before and an empty line after #pragma once).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm don't want to bother with it because I would need to code a manual check for it. clang-format does not support it and without a check it will deteriorate quickly again.

Although I agree it would look nicer.

- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Regroup
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like the idea of grouping the eckit headers, and make them the first group! 👍🏼

@@ -1,12 +1,13 @@
#include <termios.h>
#include <unistd.h>
#include "eckit/cmd/UserInput.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the typical LICENSE header to this file. Also, check if a similar header is missing on any other file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sigh something I did not check for, will do!

@pmaciel
Copy link
Member

pmaciel commented Feb 27, 2026

In my experience, IWYU is good but does generally require manual intervention -- so it is only an initial (good) guess.

Related, can you also replace all the header include guards #ifndef ... to #pragma once?

@Ozaq
Copy link
Member Author

Ozaq commented Feb 27, 2026

In my experience, IWYU is good but does generally require manual intervention -- so it is only an initial (good) guess.

Related, can you also replace all the header include guards #ifndef ... to #pragma once?

IWYU is only used to update the files, no automation, the self containment tests uses a simple compilation per header (thats why its an extra feature as it doubles the compile time)

#pragma once is so fixed by this PR, if you still see old include guards here its a bug :)

Ozaq and others added 3 commits February 27, 2026 21:00
Traditional #ifndef guards are verbose, error-prone (copy-paste of
wrong macro names), and add noise to diffs. #pragma once is supported
by all compilers we target and eliminates these issues.

- Convert 489 headers from #ifndef guards to #pragma once
- Add #pragma once to 5 headers that had no guard at all
- Skip src/eckit/contrib/ (third-party code)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Downstream projects include eckit headers in arbitrary combinations
and orders. A header that silently depends on a transitive include
will break when unrelated changes elsewhere shuffle include graphs.

Run IWYU 0.25 across the codebase to add missing direct includes
and remove unnecessary ones, so every header compiles on its own.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The IWYU cleanup made all public headers self-contained, but nothing
prevents regressions. Add a CMake test that compiles each header in
isolation — if a future change breaks self-containedness, the build
fails immediately pointing to the offending header.

Gated behind -DENABLE_TEST_SELF_CONTAINED_HEADERS=ON to avoid the
extra compile cost on regular builds.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.31%. Comparing base (34752dd) to head (38cb528).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #279      +/-   ##
===========================================
- Coverage    66.33%   66.31%   -0.03%     
===========================================
  Files         1125     1125              
  Lines        57644    57642       -2     
  Branches      4403     4403              
===========================================
- Hits         38240    38225      -15     
- Misses       19404    19417      +13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants